<?php

use yii\db\Migration;

/**
 * Handles the creation of table `{{%gerent}}`.
 */
class m200319_055443_create_gerent_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable('{{%gerent}}', [
            'id' => $this->primaryKey(),
            'username' => $this->string()->notNull()->unique(),
            'auth_key' => $this->string(32)->notNull(),
            'password_hash' => $this->string()->notNull(),
            'password_reset_token' => $this->string()->unique(),
            'email' => $this->string()->notNull()->unique(),
            'status' => $this->smallInteger()->notNull()->defaultValue(10),
            'created_at' => $this->integer()->notNull(),
            'updated_at' => $this->integer()->notNull(),
        ]);

        $this->addCommentOnTable('{{%gerent}}', '管理员表');
        $this->insert('{{%gerent}}', [
            'username' => 'xiongzai',
            'auth_key' => '',
            'password_hash' => '$2y$13$UOsE0ZIhe95yN/4o5iJoqu2sK.bEWdDZ0ai5Hw8szVaxtSWms81h2',
            'password_reset_token' =>'',
            'email' => 'admin@admin.com',
            'created_at' => time(),
            'updated_at' => time(),
        ]);

        echo PHP_EOL . PHP_EOL . '使用 xiongzai 123465 登录后台' . PHP_EOL . PHP_EOL;
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%gerent}}');
    }
}
